package com.example.mapper;

import com.example.pojo.bo.ClickBO;
import com.example.pojo.entity.PosClick;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 本文来演示
 *
 * @author 赵建云
 * @create 2023/10/13
 */
public interface PosClickMapper {
    @Insert("insert into pos_click(js_id, click_time,pos_id,pos_keyword,pos_type, click_num) value(#{jsId},#{clickTime},#{posId},#{posKeyword},#{posType},#{clickNum})")
    int saveClick(PosClick posClick);
    @Select("select id,pos_keyword,pos_type from pos_click where js_id =#{value}")
    List<ClickBO> findClick(Integer jsId);
    @Update("update pos_click set click_time=now(),click_num= click_num+1 where id = #{id} ")
    int updateClick(Integer id);

    @Select("select id,js_id,click_num from pos_click")
    List<PosClick> findAll();
    @Select("select pos_id from pos_click group by pos_id order by max(click_num) desc limit 6")
    List<Integer> findClickNumMax();
}
